<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【下载单管理】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div id="sousuo" class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                          <!--  <li>
                                <label>下载单号：</label>
                                <input type="text" name="down_no"/>
                            </li>
                            <li>
                                <label>订阅编号：</label>
                                <input type="text" name="work_no"/>
                            </li>-->
                            <li>
                                <label>用户：</label>
                                <input type="text" name="login_name"/>
                            </li>
                            <li style="display: none">
                                <select name="down_end_date" class="form-control m-b" >
                                    <option value="">---请选择---</option>
                                    <option th:text="未下载" th:value="0"></option>
                                    <option th:text="下载完成" th:value="1"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>创建时间： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="startTime"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime"  placeholder="结束时间" name="endTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div  class="btn-group-sm" id="toolbar" role="group">
               <!-- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:order:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:order:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>-->

                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:order:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            <!--    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:order:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:order:remove')}]];
        var prefix = ctx + "system/order";
        var ddid = [[${ddid}]]
        console.log("显示下载单"+ddid)
        $(function() {
            var options = {
                url: prefix + "/listxz",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "【下载单】",
                queryParams: queryParams,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '${comment}',
                    visible: false
                },
                    {
                        field: 'work_no',
                        title: '订阅编号'
                    },
                    /*{
                        field: 'down_no',
                        title: '下载单号'
                    },*/
                    {
                        field: 'login_name',
                        title: '用户'
                    },
                    {
                        field: 'resource_path',
                        title: '路径'
                    },
                    {
                        field: 'create_date',
                        title: '创建时间'
                    },
                    /*{
                        field: 'down_end_date',
                        title: '状态',
                        formatter: function(value, item, index) {
                           // console.log(item.down_end_date)
                            if (item.down_end_date == null) {
                                return '<span class="label label-warning">未下载</span>';}
                            else{
                                return '<span class="label label-primary">下载完成</span>';
                            }
                        }
                    },*/
              /*  {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                       /!* actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
*!/                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }*/]
            };
            $.table.init(options);

            function queryParams(params) {
                if(ddid!="ok"){//如果不为ok就是从订阅单跳转过去的，如果是ok就是从菜单”下载单管理进去的“
                    //隐藏掉搜索框不展示
                    $("#sousuo").css("display","none");
                    $("#toolbar").css("display","none");
                    const now = new Date();
                    var lc = now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate()+" "+"00:00:00"//开始时间
                    var ws = now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate()+" "+"23:59:59"//结束时间
                    var search = $.table.queryParams(params);
                    search.work_no = ddid;
                    search.startTime =lc;
                    search.endTime = ws;
                    return search;
                }else{
                    var search = $.table.queryParams(params);
                    return search;
                }

            }
        });
    </script>
</body>
<style>
</style>
</html>